<template>
  <div>
      <ul class="mui-table-view">
        <li class="mui-table-view-cell mui-media" v-for="(item,index) in newsList" :key="index">
            <a href="javascript:;">
                <img class="mui-media-object mui-pull-left" :src="item.img_url">
                <div class="mui-media-body">
                    <h1 class="mui-ellipsis">{{item.title}}</h1>
                    <p>
                        <span class="mui-ellipsis">发表时间：{{item.add_time | formate}}</span>
                        <span class="mui-ellipsis">点击：{{item.click}}次</span>
                    </p>
                </div>
            </a>
        </li>
	</ul>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
export default {
    data(){
      return{
          newsList:[]
      }
    },
    created(){
        this.getNewsList()
    },
    methods:{
        getNewsList(){
            // this.$http.get('api/getnewslist').then(result=>{
            //     if(result.body.status === 0){
            //         // console.log(result.body)
            //         this.newsList = result.body.message
            //     }else{
            //         Toast('新闻列表请求失败')
            //     }
            // })

            this.axios.get('http://vue.studyit.io/api/getnewslist').then(result=>{
                // console.log(result)
                if(result.status === 200 && result.data.status === 0){
                    this.newsList = result.data.message
                }else{
                    Toast('新闻列表请求失败')
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
    .mui-table-view{
        li{
            h1{
                font-size: 12px;
            }
            p{
                color:#0094ff;
                display: flex;
                justify-content: space-between;
                span{
                    font-size: 12px;
                }
            }
           
        }
    }
</style>


